<?php
	$contacts_vars = array(); 
	if (!isset($_GET['cid'])) $pid=NULL; else $pid=$_GET['cid'];
	if ($pid==NULL) if (!isset($_POST['cid'])) $pid=NULL; else $pid=$_POST['cid'];
	if ($pid!=NULL){
		$data['product']=$contactsclass->get_product_fields_with_data($pid, $_SESSION['lang']);
		$data['product']['id'] = $pid;
	}

	unset($contacts_vars);
	
 	if (!isset($_GET['cache_id'])) $product_cache_id=NULL; else $product_cache_id=$_GET['cache_id'];
	if ($product_cache_id==NULL) if (!isset($_POST['cache_id'])) $product_cache_id=NULL; else $product_cache_id=$_POST['cache_id'];

	if ((is_array($query)) && (count($query) > 0)) {
		if (isset($query['group_id']) && (intval($query['group_id']) > 0)){
			unset($query['group_id']);
			$tmp = $contactsclass->products_adv_search($query, "0", intval($query['group_id']));
		} else $tmp = $contactsclass->products_adv_search($query, "0");
		$data['search']['products'] = $tmp['products'];
		$data['search']['cache_id'] = $tmp['product_search_cache_id'];
		$data['search']['query'] = $query;
		$get_str = "";
		foreach($_GET as $key=>$value) $get_str .= "&".$key."=".$value;
		header ("location: ".$setupdata['base_href']."/index.php?cache_id=".$data['search']['cache_id']."&module=contacts".$get_str);
	} elseif ($product_cache_id != NULL){
		$tmp = $contactsclass->products_adv_search(array(), $product_cache_id);
		$data['search']['products'] = $tmp['products'];
		$data['search']['cache_id'] = $tmp['product_search_cache_id'];
		$data['search']['query'] = $tmp['query'];
	} else $data['search']['products'] = "";
?>